import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
// 配置 @ 指向 src 目录导入
import { fileURLToPath, URL } from "url";

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  css: {
    preprocessorOptions: {
      scss: { api: "modern-compiler" },
    },
  },
  build: {
    outDir: "dist",
    assetsDir: "assets",
     // 打包成单个CSS文件
    cssCodeSplit: true,
    rollupOptions: {
      input: {
        main: "index.html",
      },
    },
  },
  server: {
    port: 3100,
    open: false,
    cors: true,
  },
  resolve: {
    alias: {
      '@': fileURLToPath(new URL("./src", import.meta.url)), // 配置 @ 指向 src 目录
    },
  },
    
});
